//
//  KWNLayerViewController.m
//  KWNClient
//
//  Created by 张明磊 on 14/10/24.
//  Copyright (c) 2014年 张明磊. All rights reserved.
//

#import "KWLLayerViewController.h"
#import "KWNNetwork.h"
#import "Model_lawyerInfo.h"
#import "UIImageView+WebCache.h"
#import "Model_user.h"
#import "KWLEditLaywerViewController.h"
#import "KWLLoginViewController.h"
#import "KFWAlertView.h"
#import "KFLLaywerDetailRequest.h"
#import "Model_lawyerDetail.h"
#import "MLBlackTransition.h"
#import "KWLMyGrewupViewController.h"
#import "RESideMenu.h"

typedef NS_ENUM(NSInteger, KWNLayerViewButtonTag){
    KWNLayerPageTag_portrait               = 200,
    KWNLayerPageTag_level                             ,
    KWNLayerPageTag_title                               ,
    KWNLayerPageTag_name                            ,
    KWNLayerPageTag_sign                              ,
    KWNLayerPageTag_animation                     ,
    KWNLayerPageTag_scroll                            ,
    KWNLayerPageTag_xinyong_content          ,
    KWNLayerPageTag_wenti                            ,
    KWNLayerPageTag_wenti_content              ,
    KWNLayerPageTag_toBelow                        ,
    KWNLayerPageTag_editSelf                         ,
    KWNLayerPageTag_back                              ,
};


@interface KWLLayerViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (strong,nonatomic) Model_lawyerDetail *lawyer_data;

@property (strong, nonatomic) NSString *string_layerId;
@property (strong, nonatomic) UIView *imageView_title;
@property (strong, nonatomic) NSMutableArray *array_data;

@property (strong, nonatomic) UIView *view_above;
@property (strong, nonatomic) UIView *view_scroll;
@property (assign, nonatomic) BOOL bool_scroll;
@property (assign, nonatomic) BOOL bool_leave;
@property (weak, nonatomic) UISwipeGestureRecognizer *gestureDown;
@property (weak, nonatomic) UISwipeGestureRecognizer *gestureUp;

@property (weak, nonatomic) UIButton *button_edit;

@property (strong, nonatomic) UIImageView *imageView_portrait;
@property (strong, nonatomic) UITextView *textView_jieshao;
@property (strong, nonatomic) UILabel *label_jieshao;
@property (strong, nonatomic) UILabel *label_level;
@property (strong, nonatomic) UILabel *label_xinyong;
@property (strong, nonatomic) UILabel *label_wenti;
@property (strong, nonatomic) UILabel *label_pingjia;
@property (strong, nonatomic) UILabel *label_zhuanchang;
@property (strong, nonatomic) UILabel *label_nianxian;
@property (strong, nonatomic) UILabel *label_zhiwei;
@property (nonatomic,strong) UIButton *button_medal;
@property NSInteger layerState;
@end

@implementation KWLLayerViewController
@synthesize view_above;
@synthesize view_scroll;
@synthesize imageView_portrait;
@synthesize textView_jieshao;
@synthesize label_jieshao;
@synthesize imageView_title;
@synthesize button_medal;
@synthesize label_level;
@synthesize label_xinyong;
@synthesize label_wenti;
@synthesize label_pingjia;
@synthesize lawyer_data;
@synthesize label_zhuanchang;
@synthesize label_nianxian;
@synthesize label_zhiwei;
@synthesize layerState;

- (id)initWithLaywerWithID:(NSString *)string_id{
    self = [super init];
    if(self){
        _string_layerId = string_id;
        layerState = 0;
        [[RESideMenu sharedInstance] setPanGestureEnabled:NO];

    }
    return self;
}

- (id)initWithLaywerWithID:(NSString *)string_id andState:(NSInteger)astate;
{
    self = [super init];
    if(self){
        layerState = astate;
        _string_layerId = string_id;
        [[RESideMenu sharedInstance] setPanGestureEnabled:NO];

    }
    return self;
}

- (void)viewDidLoad{
    [super viewDidLoad];
    ///手势
    if(IOS7_VERSION){
        [self.navigationController enabledMLBlackTransition:NO];
    }
    else{
        [self.navigationController_MI setCanDragBack:NO];
    }
    
    if (IOS6_VERSION ||layerState == 1) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSwipeFrom_up) name:@"Notification_recognizer_up" object:nil];
    }

    if (IOS6_VERSION ||layerState == 1) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSwipeFrom_down) name:@"Notification_recognizer_down" object:nil];
    }

    [self UI_laywerTitle];
//    [self data_layer];
    // Do any additional setup after loading the view.
}

- (void)viewDidAppear:(BOOL)animated{
    [self data_layer];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"Notification_recognizer_down" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"Notification_recognizer_up" object:nil];
}

- (void)UI_laywerTitle{
    self.view.backgroundColor = RGB(239, 239, 244);
    
    imageView_title = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44 + IOS7_SIZE)];
    imageView_title.backgroundColor = RGB(91, 165, 229);
    [self.view addSubview:imageView_title];
    
    UIButton *button_menu = [UIButton buttonWithType:UIButtonTypeCustom];
    button_menu.frame = CGRectMake(0, IOS7_SIZE, 60, 45);
    [button_menu addTarget:self action:@selector(didClickButton_layer:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button_menu];
    button_menu.tag = KWNLayerPageTag_back;

    if(layerState == 1)
    {
        [button_menu setImage:[UIImage imageFileName:@"btn_leftList.png"] forState:UIControlStateNormal];
    }
    else
    {
        [button_menu setImage:[UIImage imageFileName:@"button_back.png"] forState:UIControlStateNormal];
    }
    
    UIButton *button_receive = [UIButton buttonWithType:UIButtonTypeCustom];
    button_receive.frame = CGRectMake(imageView_title.frame.size.width - 60, button_menu.frame.origin.y, 60, 45);
    button_receive.backgroundColor = [UIColor clearColor];
    [button_receive setImage:[UIImage imageFileName:@"button_editSelf.png"] forState:UIControlStateNormal];
    button_receive.tag = KWNLayerPageTag_editSelf;
    [button_receive addTarget:self action:@selector(didClickButton_layer:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button_receive];
    _button_edit = button_receive;
    
    UILabel *label_title = [[UILabel alloc] initWithFrame:CGRectMake(imageView_title.frame.origin.x,IOS7_SIZE + 5,imageView_title.frame.size.width,35)];
    label_title.backgroundColor = [UIColor clearColor];
    label_title.textColor = ColorOfTitle;
    label_title.textAlignment = NSTextAlignmentCenter;
    label_title.font = [UIFont fontWithName:@"Helvetica-Bold" size:16.0f];
    [self.view addSubview:label_title];
    label_title.text = @"律师介绍";
}

- (void)data_layer{
    [SVProgressHUD showWithStatus:@"加载中..." maskType:SVProgressHUDMaskTypeClear];
    
    KFLLaywerDetailRequest *request = [[KFLLaywerDetailRequest alloc] initRequest];
    [request startToRequestWithBlock:^(NSInteger stateCode, NSMutableArray *result) {
        switch (stateCode) {
            case 10000:{
                [SVProgressHUD dismiss];
                [Model_user sharedInstance].bool_isLoadLawyer = YES;
                lawyer_data = [result objectAtIndex:0];
                if (view_above) {
                    [self lawyerDataToView];
                }
                else
                {
                    [self UI_layer];
                }
            }break;
            case 10003:{
                [SVProgressHUD dismiss];
                [self layerTokenIsFailure];
            }break;
            default:{
                NSString *string_msg  = result[0];
                [SVProgressHUD dismissWithError:string_msg afterDelay:1.5];
            }break;
        }

    }];
}

// CE 快法务 KLW 2015-02-06
#pragma mark - 账号被替换下线提示 -
- (void)layerTokenIsFailure{
    UIAlertView *alter_login;
    if(IOS8_VERSION){
        alter_login = [[UIAlertView alloc] initWithTitle:@"您的来问律师账号已在其它地方登录，请您重新登录此设备。如果不是您的操作，您的密码可能已泄露，请及时更改密码，或联系快问律师客服邮箱laiwenlvshi@kuaifawu.com。" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
    }
    else{
        alter_login = [[UIAlertView alloc] initWithTitle:nil message:@"您的来问律师账号已在其它地方登录，请您重新登录此设备。如果不是您的操作，您的密码可能已泄露，请及时更改密码，或联系快问律师客服邮箱laiwenlvshi@kuaifawu.com。" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
    }
    alter_login.tag = 10003;
    [alter_login show];
}

#pragma mark - alertView -
/**
 *  账号被替换下线
 */
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    switch (alertView.tag) {
            //账号替换
        case 10003:{
            KWLLoginViewController *login = [[KWLLoginViewController alloc] initWithTag:6];
            [self pushViewController:login];
        }break;
            
        default:
            break;
    }
}

- (void)UI_layer{
//    Model_lawyerInfo *laywer = _array_data[0];
    NSString *string_uid = [[Model_user sharedInstance] getUserID];
    if(![string_uid isEqualToString:lawyer_data.string_id]){
        _button_edit.hidden = YES;
    }
    else{
        NSString *string_content = [NSString stringWithFormat:@"荣升%@级，恭喜！请再接再厉！高等级特权即将上线，敬请关注",lawyer_data.string_class];
        [[Model_user sharedInstance] setLaywerLevelWith:lawyer_data.string_class];
        
        if([[Model_user sharedInstance] getLayerIsUp]){
            double delayInSeconds = 0.5;
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                //code to be executed on the main queue after delay
                [KFWAlertView showKFWAlertViewWithTitle:nil titleImage:[UIImage imageFileName:@"laywerup.png"] andMessage:string_content cancelbtn:@"确定"];
            });
        }
    }
    view_above = [[UIView alloc] initWithFrame:CGRectMake(0, imageView_title.frame.origin.y + imageView_title.frame.size.height - Iphone5_size(0, 65), self.view.frame.size.width, self.view.frame.size.height - imageView_title.frame.size.height)];
    view_above.backgroundColor = RGB(239,239,244);
    view_above.userInteractionEnabled = YES;
    [self.view insertSubview:view_above belowSubview:imageView_title];
    
    UIImageView *imageView_back = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 220)];
    imageView_back.image = [UIImage imageFileName:@"layerBack.png"];
    imageView_back.userInteractionEnabled = YES;
    [view_above addSubview:imageView_back];
    
    imageView_portrait = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2 - 53, 167, 105, 105)];
    [imageView_portrait sd_setImageWithURL:[NSURL URLWithString:lawyer_data.string_head_src] placeholderImage:[UIImage imageFileName:Default_portrait]];
    [imageView_portrait setContentMode:UIViewContentModeScaleAspectFill];
    imageView_portrait.layer.masksToBounds = YES;
    imageView_portrait.layer.cornerRadius = 53.0;
    imageView_portrait.layer.borderWidth = 1.0;//边框宽度
    imageView_portrait.layer.borderColor = [UIColor whiteColor].CGColor;//边框颜色
    imageView_portrait.tag = 20;
    imageView_portrait.tag = KWNLayerPageTag_portrait;
    imageView_portrait.userInteractionEnabled = YES;

    [view_above addSubview:imageView_portrait];
    
    label_level = [[UILabel alloc] initWithFrame:CGRectMake(imageView_portrait.frame.origin.x + imageView_portrait.frame.size.width - 30, imageView_portrait.frame.origin.y + imageView_portrait.frame.size.height - 28, 60, 28)];
    label_level.backgroundColor = RGB(69,219,180);
    label_level.text = [NSString stringWithFormat:@"LV. %@",lawyer_data.string_class];
    label_level.textColor = [UIColor whiteColor];
    label_level.textAlignment = NSTextAlignmentCenter;
    label_level.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:16];
    label_level.layer.cornerRadius = 13;
    label_level.userInteractionEnabled = YES;
    label_level.clipsToBounds = YES;
    [view_above addSubview:label_level];
    label_level.tag = KWNLayerPageTag_level;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(label_levelTap:)];
    [label_level addGestureRecognizer:tap];
    
    UILabel *label_name = [[UILabel alloc] initWithFrame:CGRectMake(100, imageView_portrait.frame.origin.y + imageView_portrait.frame.size.height + Iphone5_size(20, 0), 120, 40)];
    label_name.backgroundColor = [UIColor clearColor];
    label_name.text = lawyer_data.string_realname;
    label_name.textColor = [UIColor blackColor];
    label_name.textAlignment = NSTextAlignmentCenter;
    label_name.font = [UIFont fontWithName:@"Helvetica-Bold" size:28.0f];
    label_name.userInteractionEnabled = YES;
    [view_above addSubview:label_name];
    label_name.tag = KWNLayerPageTag_name;
    
    UIView *view_animation = [[UIView alloc] initWithFrame:CGRectMake(0, label_name.frame.origin.y + label_name.frame.size.height - Iphone5_size(-60, 25) + IOS6_SIZE, 320, 180)];
    view_animation.backgroundColor = [UIColor clearColor];
    [self.view addSubview:view_animation];
    view_animation.userInteractionEnabled = YES;
    view_animation.tag = KWNLayerPageTag_animation;
    
    label_jieshao = [[UILabel alloc] initWithFrame:CGRectMake(15, Iphone5_size(0, 15), 290, 60)];
    label_jieshao.backgroundColor = [UIColor clearColor];
    label_jieshao.text = lawyer_data.string_signatu;
    label_jieshao.textColor = RGB(149, 149, 149);
    label_jieshao.textAlignment = NSTextAlignmentCenter;
    label_jieshao.numberOfLines = 2;
    label_jieshao.font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0f];
    label_jieshao.userInteractionEnabled = YES;
    [view_animation addSubview:label_jieshao];
    
    button_medal = [UIButton buttonWithType:UIButtonTypeCustom];
    button_medal.frame = CGRectMake(21, label_jieshao.frame.origin.y + label_jieshao.frame.size.height + Iphone5_size(5, 5), 62, 64);
    if (lawyer_data.string_label.integerValue == 1) {
        [button_medal setBackgroundImage:[UIImage imageFileName:@"grewup_badge_answer.png"] forState:UIControlStateNormal];
    }
    else if (lawyer_data.string_label.integerValue == 2)
    {
        [button_medal setBackgroundImage:[UIImage imageFileName:@"grewup_badge_star.png"] forState:UIControlStateNormal];
    }
    else
    {
        [button_medal setBackgroundImage:[UIImage imageFileName:@"grewup_badge.png"] forState:UIControlStateNormal];
    }
    [button_medal addTarget:self action:@selector(button_medalClick:) forControlEvents:UIControlEventTouchUpInside];
    [view_animation addSubview:button_medal];

    label_pingjia = [UIUtils creatLabel];
    label_pingjia.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:18];
    label_pingjia.textColor = RGB(231, 76, 81);
    label_pingjia.textAlignment = NSTextAlignmentCenter;
    label_pingjia.frame = CGRectMake(MainScreenWidth - 3 * 2 - 88 * 1 - 53 - 5 - 73, button_medal.frame.origin.y + 13, 53, 25);
    label_pingjia.text = lawyer_data.string_evaluation;
//    label_pingjia.text = @"100";
    label_pingjia.userInteractionEnabled = YES;
    [view_animation addSubview:label_pingjia];
//    [label_pingjia borderGreen];
    
    UILabel *label_pingjia_content = [UIUtils creatLabel];
    label_pingjia_content.frame = CGRectMake(label_pingjia.frame.origin.x, label_pingjia.frame.origin.y + label_pingjia.frame.size.height + 6, 53, 20);
    label_pingjia_content.textAlignment = NSTextAlignmentCenter;
    label_pingjia_content.textColor = RGB(149, 149, 149);
    label_pingjia_content.text = @"评价指数";
    label_pingjia_content.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
    label_pingjia_content.userInteractionEnabled = YES;
    [view_animation addSubview:label_pingjia_content];

    label_wenti = [[UILabel alloc] initWithFrame:CGRectMake(MainScreenWidth - 3 - 88*1 - 73 - 5, label_pingjia.frame.origin.y, 73, 25)];
    label_wenti.backgroundColor = [UIColor clearColor];
    if(lawyer_data.string_solvecount){
        label_wenti.text = [NSString stringWithFormat:@"%@",lawyer_data.string_solvecount];
    }
    else{
        label_wenti.text = @"0";
    }
    label_wenti.textColor = RGB(71,145,226);
    label_wenti.textAlignment = NSTextAlignmentCenter;
    label_wenti.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:18];
    label_wenti.userInteractionEnabled = YES;
    [view_animation addSubview:label_wenti];

    UILabel *label_wenti_content = [[UILabel alloc] initWithFrame:CGRectMake(label_wenti.frame.origin.x, label_wenti.frame.origin.y + label_wenti.frame.size.height + 6, label_wenti.frame.size.width, 20)];
    label_wenti_content.backgroundColor = [UIColor clearColor];
    label_wenti_content.text = @"解决问题";
    label_wenti_content.textColor = RGB(149, 149, 149);
    label_wenti_content.textAlignment = NSTextAlignmentCenter;
    label_wenti_content.userInteractionEnabled = YES;
    label_wenti_content.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
    [view_animation addSubview:label_wenti_content];

    label_xinyong = [[UILabel alloc] initWithFrame:CGRectMake(MainScreenWidth - 88 - 8, label_pingjia.frame.origin.y, 88, 25)];
    label_xinyong.backgroundColor = [UIColor clearColor];
    label_xinyong.text = lawyer_data.string_integral;
    label_xinyong.textColor = RGB(71,145,226);
    label_xinyong.textAlignment = NSTextAlignmentCenter;
    label_xinyong.userInteractionEnabled = YES;
    label_xinyong.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:18];
    [view_animation addSubview:label_xinyong];

    UILabel *label_xinyong_content = [[UILabel alloc] initWithFrame:CGRectMake(label_xinyong.frame.origin.x, label_xinyong.frame.origin.y + label_xinyong.frame.size.height + 6, label_xinyong.frame.size.width, 20)];
    label_xinyong_content.backgroundColor = [UIColor clearColor];
    label_xinyong_content.text = @"我的积分";
    label_xinyong_content.textColor = RGB(149, 149, 149);
    label_xinyong_content.userInteractionEnabled = YES;
    label_xinyong_content.textAlignment = NSTextAlignmentCenter;
    label_xinyong_content.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
    [view_animation addSubview:label_xinyong_content];

    UIButton *button_toBelow = [UIButton buttonWithType:UIButtonTypeCustom];
    button_toBelow.frame = CGRectMake(114, label_wenti_content.frame.origin.y + label_wenti_content.frame.size.height + 5, 92, 41);
    button_toBelow.backgroundColor = [UIColor clearColor];
    [button_toBelow setImage:[UIImage imageFileName:@"button_toBelow.png"] forState:UIControlStateNormal];
    [button_toBelow addTarget:self action:@selector(didClickButton_toBelow:)forControlEvents:UIControlEventTouchUpInside];
    [view_animation addSubview:button_toBelow];
    
    UISwipeGestureRecognizer *recognizer_up = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom_up)];
    recognizer_up.direction = UISwipeGestureRecognizerDirectionUp;
    [self.view addGestureRecognizer:recognizer_up];
    _gestureUp = recognizer_up;
    
    
}

#pragma mark - 奖章点击事件 -
- (void)button_medalClick:(id)sender
{
    NSString *string_uid = [[Model_user sharedInstance] getUserID];

    if ([lawyer_data.string_id isEqualToString:string_uid]) {
        KWLMyGrewupViewController *control = [[KWLMyGrewupViewController alloc] initWithGrewupLeftBtnType:KFWGrewupLeftBtnBackType andModel:KFWGrewupModelTypeMyMedal];
        [self pushViewController:control];
    }
}
#pragma mark - 等级label点击 -
- (void)label_levelTap:(UIGestureRecognizer *)tap
{
    NSString *string_uid = [[Model_user sharedInstance] getUserID];
    
    if ([lawyer_data.string_id isEqualToString:string_uid]) {
        KWLMyGrewupViewController *control = [[KWLMyGrewupViewController alloc] initWithGrewupLeftBtnType:KFWGrewupLeftBtnBackType andModel:KFWGrewupModelTypeMyLevel];
        [self pushViewController:control];
    }

}

- (void)lawyerDataToView
{
    [imageView_portrait sd_setImageWithURL:[NSURL URLWithString:lawyer_data.string_head_src] placeholderImage:[UIImage imageFileName:Default_portrait]];
    label_level.text = [NSString stringWithFormat:@"LV. %@",lawyer_data.string_class];
    
    UILabel *label_name = (UILabel *)[view_above viewWithTag:KWNLayerPageTag_name];
    label_name.text = lawyer_data.string_realname;
    
    label_jieshao.text = lawyer_data.string_signatu;
    
    if (lawyer_data.string_label.integerValue == 1) {
        [button_medal setBackgroundImage:[UIImage imageFileName:@"grewup_badge_answer.png"] forState:UIControlStateNormal];
    }
    else if (lawyer_data.string_label.integerValue == 2)
    {
        [button_medal setBackgroundImage:[UIImage imageFileName:@"grewup_badge_star.png"] forState:UIControlStateNormal];
    }
    else
    {
        [button_medal setBackgroundImage:[UIImage imageFileName:@"grewup_badge.png"] forState:UIControlStateNormal];
    }
    
    label_pingjia.text = lawyer_data.string_evaluation;

    if(lawyer_data.string_solvecount){
        label_wenti.text = [NSString stringWithFormat:@"%@",lawyer_data.string_solvecount];
    }
    else{
        label_wenti.text = @"0";
    }

    label_xinyong.text = lawyer_data.string_integral;

    if (view_scroll) {
        UITableView *tableView_content = (UITableView *)[view_scroll viewWithTag:TagOfView];
        if (tableView_content) {
            [tableView_content reloadData];
        }
        
        label_zhuanchang.text = [NSString stringWithFormat:@"专长：%@",lawyer_data.string_goodatfield];
        label_nianxian.text = [NSString stringWithFormat:@"%@年经验",lawyer_data.string_life];
        label_zhiwei.text = [NSString stringWithFormat:@"%@",lawyer_data.string_position];
    }
}

- (void)didClickButton_layer:(UIButton *)button{    
    switch (button.tag) {
        case KWNLayerPageTag_editSelf:{
            Model_lawyerInfo *laywer = _array_data[0];
            KWLEditLaywerViewController *controller_edit = [[KWLEditLaywerViewController alloc] initWithModel:laywer];
            [self pushViewController:controller_edit];
        }break;
        case KWNLayerPageTag_back:{
            if (layerState == 1)
            {
                if(IOS7_VERSION){
                    [self.navigationController enabledMLBlackTransition:YES];
                }
                else{
                    [self.navigationController_MI setCanDragBack:YES];
                }

                [[RESideMenu sharedInstance] presentMenuViewController];
            }
            else
            {
                ///手势
                if(IOS7_VERSION){
                    [self.navigationController enabledMLBlackTransition:YES];
                }
                else{
                    [self.navigationController_MI setCanDragBack:YES];
                }
                
                [self popViewController];

            }
        }break;
        default:
            break;
    }
}

#pragma mark - 点击下滑 -
/**
 *  点击下滑
 */
- (void)didClickButton_toBelow:(UIButton *)button{
    _bool_scroll = NO;
    _bool_leave = YES;
    _gestureDown.enabled = YES;
    _gestureUp.enabled = NO;
    
    [UIView beginAnimations:@"100" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [UIView setAnimationDuration:0.3f];
    [UIView setAnimationRepeatCount:1];
    [UIView setAnimationBeginsFromCurrentState:YES];
    
    view_above.frame = CGRectMake(view_above.frame.origin.x, view_above.frame.origin.y - self.view.frame.size.height/4 - Iphone5_size(25, -10), view_above.frame.size.width, view_above.frame.size.height);
    
    UILabel *label_name = (UILabel *)[view_above viewWithTag:KWNLayerPageTag_name];
    label_name.frame = CGRectMake(label_name.frame.origin.x, label_name.frame.origin.y - Iphone5_size(35, 15), label_name.frame.size.width, label_name.frame.size.height);
    
    label_level.frame = CGRectMake(label_level.frame.origin.x - 15, label_level.frame.origin.y - 20, label_level.frame.size.width, label_level.frame.size.height);
//    UIImageView *imageView_title = (UIImageView *)[view_above viewWithTag:KWNLayerPageTag_title];
//    imageView_title.frame = CGRectMake(imageView_title.frame.origin.x - 15, imageView_title.frame.origin.y - 20, imageView_title.frame.size.width, imageView_title.frame.size.height);
    
    UIView *view_animation = (UIView *)[self.view viewWithTag:KWNLayerPageTag_animation];
    //view_animation.alpha = 0.0;
    
    imageView_portrait = (UIImageView *)[view_above viewWithTag:KWNLayerPageTag_portrait];
    imageView_portrait.frame = CGRectMake(imageView_portrait.frame.origin.x + 20, imageView_portrait.frame.origin.y + 20, imageView_portrait.frame.size.width - 40, imageView_portrait.frame.size.height - 40);
    imageView_portrait.layer.cornerRadius = 33.0;
    
    label_level.frame = CGRectMake(label_level.frame.origin.x, label_level.frame.origin.y + 10, label_level.frame.size.width - 20, label_level.frame.size.height - 9);
    label_level.layer.cornerRadius = 9;
    label_level.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:12];
    
    [UIView commitAnimations];
    
    [UIView beginAnimations:@"101" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [UIView setAnimationDuration:0.5f];
    [UIView setAnimationRepeatCount:1];
    [UIView setAnimationBeginsFromCurrentState:YES];
    if(view_scroll){
        view_scroll.alpha = 1.0;
    }
    else{
//        Model_lawyerInfo *laywer = _array_data[0];
        
        view_scroll = [[UIView alloc] initWithFrame:CGRectMake(0, 185 + IOS7_SIZE - Iphone5_size(0, 10), 320, self.view.frame.size.height - 185 - IOS7_SIZE - Iphone5_size(0, 10))];
        view_scroll.backgroundColor = [UIColor clearColor];
        [self.view addSubview:view_scroll];
        view_scroll.alpha = 0.0;
        
        UILabel *label_kind = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 65, 20)];
        label_kind.backgroundColor = [UIColor clearColor];
        label_kind.text = @"标签：";
        label_kind.textColor = [UIColor blackColor];
        label_kind.textAlignment = NSTextAlignmentLeft;
        label_kind.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [view_scroll addSubview:label_kind];
        
        label_zhuanchang = [UIUtils creatLabel];
        label_zhuanchang.backgroundColor = RGB(252, 207, 83);
        label_zhuanchang.font = FontOfSystem(12);
        label_zhuanchang.frame = CGRectMake(label_kind.frame.origin.x + label_kind.frame.size.width, 0, 90, 20);
        label_zhuanchang.layer.cornerRadius = 10;
        label_zhuanchang.textColor = RGB(178, 114, 24);
        label_zhuanchang.clipsToBounds = YES;
        label_zhuanchang.textAlignment = NSTextAlignmentCenter;
        label_zhuanchang.text = [NSString stringWithFormat:@"专长：%@",lawyer_data.string_goodatfield];
        NSArray *arr = [UIUtils getQuestionTypeWithkind:lawyer_data.string_goodatfield.integerValue];
        label_zhuanchang.text = [NSString stringWithFormat:@"专长：%@",[arr objectAtIndex:1]];
        [view_scroll addSubview:label_zhuanchang];

        label_nianxian = [UIUtils creatLabel];
        label_nianxian.backgroundColor = RGB(252, 207, 83);
        label_nianxian.font = FontOfSystem(12);
        label_nianxian.frame = CGRectMake(label_zhuanchang.frame.origin.x + label_zhuanchang.frame.size.width + 5, 0, 63, 20);
        label_nianxian.layer.cornerRadius = 10;
        label_nianxian.textColor = RGB(178, 114, 24);
        label_nianxian.clipsToBounds = YES;
        label_nianxian.textAlignment = NSTextAlignmentCenter;
        label_nianxian.text = [NSString stringWithFormat:@"%@年经验",lawyer_data.string_life];
        [view_scroll addSubview:label_nianxian];

        label_zhiwei = [UIUtils creatLabel];
        label_zhiwei.backgroundColor = RGB(252, 207, 83);
        label_zhiwei.font = FontOfSystem(12);
        label_zhiwei.frame = CGRectMake(label_nianxian.frame.origin.x + label_nianxian.frame.size.width + 5, 0, 63, 20);
        label_zhiwei.layer.cornerRadius = 10;
        label_zhiwei.textColor = RGB(178, 114, 24);
        label_zhiwei.clipsToBounds = YES;
        label_zhiwei.textAlignment = NSTextAlignmentCenter;
        label_zhiwei.text = [NSString stringWithFormat:@"%@",lawyer_data.string_position];
        [view_scroll addSubview:label_zhiwei];

        UIView *view_lineOne = [[UIView alloc] initWithFrame:CGRectMake(label_kind.frame.origin.x, label_kind.frame.origin.y + label_kind.frame.size.height + 10, 270, 1.0f)];
        view_lineOne.backgroundColor = RGB(211,211,211);
        [view_scroll addSubview:view_lineOne];
        
        UITableView *tableView_content = [[UITableView alloc] initWithFrame:CGRectMake(0, view_lineOne.frame.origin.y + 1, 320, view_scroll.frame.size.height - view_lineOne.frame.origin.y - 1)];
        tableView_content.backgroundColor = [UIColor clearColor];
        tableView_content.separatorStyle = UITableViewCellSeparatorStyleNone;
        tableView_content.delegate = self;
        tableView_content.dataSource = self;
        tableView_content.tag = TagOfView;
        [view_scroll addSubview:tableView_content];
        
        UISwipeGestureRecognizer *recognizer_down = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom_down)];
        recognizer_down.direction = UISwipeGestureRecognizerDirectionDown;
        [self.view addGestureRecognizer:recognizer_down];
        _gestureDown = recognizer_down;
        

        view_scroll.alpha = 1.0;
    }
    [UIView commitAnimations];
    view_animation.alpha = 0.0;
}

#pragma mark - tableView回调 -
/**
 *  tableView回调
 */
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"LayerCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.backgroundColor = [UIColor clearColor];
        cell.contentView.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UILabel *label_address = [UIUtils creatLabel];
        label_address.textColor = [UIColor blackColor];
        label_address.frame = CGRectMake(20, 10, 65, 25);
        label_address.textAlignment = NSTextAlignmentLeft;
        label_address.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        label_address.text = @"所在地区：";
        [cell addSubview:label_address];
        
        UILabel *label_address_content = [UIUtils creatLabel];
        label_address_content.frame = CGRectMake(label_address.frame.origin.x + label_address.frame.size.width, 10, MainScreenWidth - 20*2 - label_address.frame.size.width, 25);
        label_address_content.textColor = RGB(105, 105, 106);
        label_address_content.font = FontOfSystem(13);
        NSInteger kind_area = lawyer_data.string_area.integerValue;
        switch (kind_area) {
            case 0:{
                label_address_content.text = @"北京市";
            }break;
            case 1:{
                label_address_content.text = @"上海市";
            }break;
            case 2:{
                label_address_content.text = @"广州";
            }break;
            case 3:{
                label_address_content.text = @"深圳市";
            }break;
            case 4:{
                label_address_content.text = @"天津市";
            }break;
            case 5:{
                label_address_content.text = @"杭州市";
            }break;
            case 6:{
                label_address_content.text = @"成都市";
            }break;
            case 7:{
                label_address_content.text = @"重庆市";
            }break;
            case 8:{
                label_address_content.text = @"其他地区";
            }break;
            default:
                break;
        }
        [cell addSubview:label_address_content];
        
        UILabel *label_shanchang = [UIUtils creatLabel];
        label_shanchang.textColor = [UIColor blackColor];
        label_shanchang.frame = CGRectMake(label_address.frame.origin.x, label_address.frame.origin.y + label_address.frame.size.height, label_address.frame.size.width, label_address.frame.size.height);
        label_shanchang.textAlignment = NSTextAlignmentLeft;
        label_shanchang.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        label_shanchang.text = @"擅长领域：";
        [cell addSubview:label_shanchang];
        
        UILabel *label_shanchang_content = [UIUtils creatLabel];
        label_shanchang_content.textColor = RGB(105, 105, 106);
        label_shanchang_content.font = FontOfSystem(13);
        label_shanchang_content.numberOfLines = 0;
//        CGFloat height_shanchang_content = [UIUtils heightFor:lawyer_data.string_shanchang withFont:FontOfSystem(13) labWidth:label_address_content.frame.size.width];
        CGSize labelsize = [UIUtils cgrectFor:lawyer_data.string_shanchang withFont:FontOfSystem(13) labWidth:label_address_content.frame.size.width];
        CGFloat height_shanchang_content = labelsize.height;
        
        if (IOS7_VERSION) {
            label_shanchang_content.frame = CGRectMake(label_address_content.frame.origin.x, label_shanchang.frame.origin.y + 5, label_address_content.frame.size.width, height_shanchang_content);
        }
        else
        {
            label_shanchang_content.frame = CGRectMake(label_address_content.frame.origin.x, label_shanchang.frame.origin.y, label_address_content.frame.size.width, height_shanchang_content);
        }
        label_shanchang_content.text = lawyer_data.string_shanchang;
        [cell addSubview:label_shanchang_content];

        UILabel *label_zizhi = [UIUtils creatLabel];
        label_zizhi.text = @"执业资质：";
        label_zizhi.frame = CGRectMake(label_shanchang.frame.origin.x, label_shanchang_content.frame.origin.y + label_shanchang_content.frame.size.height, label_shanchang.frame.size.width, 25);
        label_zizhi.textColor = [UIColor blackColor];
        label_zizhi.textAlignment = NSTextAlignmentLeft;
        label_zizhi.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [cell addSubview:label_zizhi];

        UILabel *label_zizhi_content = [[UILabel alloc] initWithFrame:CGRectMake(label_zizhi.frame.origin.x + label_zizhi.frame.size.width, label_zizhi.frame.origin.y, label_shanchang_content.frame.size.width, 25)];
        label_zizhi_content.backgroundColor = [UIColor clearColor];
        label_zizhi_content.text = lawyer_data.string_qualificati;
        label_zizhi_content.textColor = RGB(105, 105, 106);
        label_zizhi_content.textAlignment = NSTextAlignmentLeft;
        label_zizhi_content.font = FontOfSystem(13);
        [cell addSubview:label_zizhi_content];
        
        UILabel *label_nianxian_ = [UIUtils creatLabel];
        label_nianxian_.frame = CGRectMake(label_zizhi.frame.origin.x, label_zizhi.frame.origin.y + label_zizhi.frame.size.height, label_zizhi.frame.size.width, label_zizhi.frame.size.height);
        label_nianxian_.text = @"从业年限：";
        label_nianxian_.textColor = [UIColor blackColor];
        label_nianxian_.textAlignment = NSTextAlignmentLeft;
        label_nianxian_.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [cell addSubview:label_nianxian_];

        UILabel *label_nianxian_content = [UIUtils creatLabel];
        label_nianxian_content.frame = CGRectMake(label_zizhi_content.frame.origin.x, label_zizhi_content.frame.origin.y + label_zizhi_content.frame.size.height, label_zizhi_content.frame.size.width, label_zizhi_content.frame.size.height);
        label_nianxian_content.text = [NSString stringWithFormat:@"%@年",lawyer_data.string_life];
        label_nianxian_content.textColor = RGB(105, 105, 106);
        label_nianxian_content.textAlignment = NSTextAlignmentLeft;
        label_nianxian_content.font = FontOfSystem(13);
        [cell addSubview:label_nianxian_content];

        UILabel *label_jiaoyu = [UIUtils creatLabel];
        label_jiaoyu.frame = CGRectMake(label_nianxian_.frame.origin.x, label_nianxian_.frame.origin.y + label_nianxian_.frame.size.height, label_nianxian_.frame.size.width, label_nianxian_.frame.size.height);
        label_jiaoyu.text = @"教育经历：";
        label_jiaoyu.textColor = [UIColor blackColor];
        label_jiaoyu.textAlignment = NSTextAlignmentLeft;
        label_jiaoyu.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [cell addSubview:label_jiaoyu];

        UILabel *label_jiaoyu_content = [UIUtils creatLabel];
        label_jiaoyu_content.frame = CGRectMake(label_nianxian_content.frame.origin.x, label_nianxian_content.frame.origin.y + label_nianxian_content.frame.size.height, label_nianxian_content.frame.size.width, label_nianxian_content.frame.size.height);
        label_jiaoyu_content.text = [NSString stringWithFormat:@"%@",lawyer_data.string_education];
        label_jiaoyu_content.textColor = RGB(105, 105, 106);
        label_jiaoyu_content.textAlignment = NSTextAlignmentLeft;
        label_jiaoyu_content.font = FontOfSystem(13);
        [cell addSubview:label_jiaoyu_content];

        UILabel *label_jigou = [UIUtils creatLabel];
        label_jigou.frame = CGRectMake(label_jiaoyu.frame.origin.x, label_jiaoyu.frame.origin.y + label_jiaoyu.frame.size.height, label_jiaoyu.frame.size.width, label_jiaoyu.frame.size.height);
        label_jigou.text = @"执业机构：";
        label_jigou.textColor = [UIColor blackColor];
        label_jigou.textAlignment = NSTextAlignmentLeft;
        label_jigou.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [cell addSubview:label_jigou];

        UILabel *label_jigou_content = [UIUtils creatLabel];
        label_jigou_content.frame = CGRectMake(label_jiaoyu_content.frame.origin.x, label_jiaoyu_content.frame.origin.y + label_jiaoyu_content.frame.size.height, label_jiaoyu_content.frame.size.width, label_jiaoyu_content.frame.size.height);
        label_jigou_content.backgroundColor = [UIColor clearColor];
        label_jigou_content.text = lawyer_data.string_mechanism;
        label_jigou_content.textColor = RGB(105, 105, 106);
        label_jigou_content.textAlignment = NSTextAlignmentLeft;
        label_jigou_content.font = FontOfSystem(13);
        [cell addSubview:label_jigou_content];

        UILabel *label_zhiwei_ = [UIUtils creatLabel];
        label_zhiwei_.frame = CGRectMake(label_jigou.frame.origin.x, label_jigou.frame.origin.y + label_jigou.frame.size.height, label_jigou.frame.size.width, label_jigou.frame.size.height);
        label_zhiwei_.text = @"现任职位：";
        label_zhiwei_.textColor = [UIColor blackColor];
        label_zhiwei_.textAlignment = NSTextAlignmentLeft;
        label_zhiwei_.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [cell addSubview:label_zhiwei_];

        UILabel *label_zhiwei_content = [UIUtils creatLabel];
        label_zhiwei_content.frame = CGRectMake(label_jigou_content.frame.origin.x, label_jigou_content.frame.origin.y + label_jigou_content.frame.size.height, label_jigou_content.frame.size.width, label_jigou_content.frame.size.height);
        label_zhiwei_content.text = lawyer_data.string_position;
        label_zhiwei_content.textColor = RGB(105, 105, 106);
        label_zhiwei_content.textAlignment = NSTextAlignmentLeft;
        label_zhiwei_content.font = FontOfSystem(13);
        [cell addSubview:label_zhiwei_content];

        UILabel *label_dizhi = [UIUtils creatLabel];
        label_dizhi.frame = CGRectMake(label_zhiwei_.frame.origin.x, label_zhiwei_.frame.origin.y + label_zhiwei_.frame.size.height, label_zhiwei_.frame.size.width, label_zhiwei_.frame.size.height);
        label_dizhi.text = @"办公地址：";
        label_dizhi.textColor = [UIColor blackColor];
        label_dizhi.textAlignment = NSTextAlignmentLeft;
        label_dizhi.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [cell addSubview:label_dizhi];

        UILabel *label_dizhi_content = [UIUtils creatLabel];
        label_dizhi_content.textColor = RGB(105, 105, 106);
        label_dizhi_content.textAlignment = NSTextAlignmentLeft;
        label_dizhi_content.font = FontOfSystem(13);
        label_dizhi_content.numberOfLines = 0;
        CGFloat height_dizhi_content = [UIUtils heightFor:lawyer_data.string_office_address withFont:FontOfSystem(13) labWidth:label_zhiwei_content.frame.size.width];
        if (IOS7_VERSION) {
            label_dizhi_content.frame = CGRectMake(label_zhiwei_content.frame.origin.x, label_dizhi.frame.origin.y + 5, label_zhiwei_content.frame.size.width, height_dizhi_content);
        }
        else
        {
            label_dizhi_content.frame = CGRectMake(label_zhiwei_content.frame.origin.x, label_zhiwei_content.frame.origin.y + label_zhiwei_content.frame.size.height, label_zhiwei_content.frame.size.width, height_dizhi_content);
        }
        label_dizhi_content.text = lawyer_data.string_office_address;
        [cell addSubview:label_dizhi_content];

        UIView *view_lineTwo = [[UIView alloc] initWithFrame:CGRectMake(label_dizhi.frame.origin.x, label_dizhi_content.frame.origin.y + label_dizhi_content.frame.size.height + 10, 270, 1.0f)];
        view_lineTwo.backgroundColor = RGB(211,211,211);
        [cell addSubview:view_lineTwo];

        UILabel *label_jieshao_ = [UIUtils creatLabel];
        label_jieshao_.frame = CGRectMake(label_dizhi.frame.origin.x, view_lineTwo.frame.origin.y + 10, label_dizhi.frame.size.width, label_dizhi.frame.size.height);
        label_jieshao_.text = @"个人简介：";
        label_jieshao_.textColor = [UIColor blackColor];
        label_jieshao_.textAlignment = NSTextAlignmentLeft;
        label_jieshao_.font = [UIFont fontWithName:@"Helvetica-Bold" size:13.0f];
        [cell addSubview:label_jieshao_];

        UILabel *label_jieshao_content = [UIUtils creatLabel];
        label_jieshao_content.textColor = RGB(105, 105, 106);
        label_jieshao_content.textAlignment = NSTextAlignmentLeft;
        label_jieshao_content.font = FontOfSystem(13);
        label_jieshao_content.numberOfLines = 0;
        CGFloat height_jieshao_content = [UIUtils heightFor:lawyer_data.string_intro withFont:FontOfSystem(13) labWidth:label_dizhi_content.frame.size.width];
        if (IOS7_VERSION) {
            label_jieshao_content.frame = CGRectMake(label_dizhi_content.frame.origin.x, label_jieshao_.frame.origin.y + 5, label_dizhi_content.frame.size.width, height_jieshao_content);
        }
        else
        {
            label_jieshao_content.frame = CGRectMake(label_dizhi_content.frame.origin.x, label_jieshao_.frame.origin.y, label_dizhi_content.frame.size.width, height_jieshao_content);
        }
        label_jieshao_content.text = lawyer_data.string_intro;
        [cell addSubview:label_jieshao_content];
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    CGFloat width_label = MainScreenWidth - 20*2 - 65;
    CGFloat height_shanchang_content = [UIUtils heightFor:lawyer_data.string_shanchang withFont:FontOfSystem(13) labWidth:width_label];
    CGFloat height_dizhi_content = [UIUtils heightFor:lawyer_data.string_office_address withFont:FontOfSystem(13) labWidth:width_label];
    CGFloat height_jieshao_content = [UIUtils heightFor:lawyer_data.string_intro withFont:FontOfSystem(13) labWidth:width_label];

    return 10*2 + 25*6 + height_shanchang_content + height_dizhi_content + height_jieshao_content + 40;   //最后10为拓展
}

#pragma mark -
#pragma mark UIScrollDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView.tag != TagOfView) {
        if(scrollView.contentOffset.y <= 0 && _bool_scroll == NO && _bool_leave == YES){
            _bool_scroll = YES;
            _gestureDown.enabled = NO;
            _gestureUp.enabled = YES;
            [UIView beginAnimations:@"101" context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
            [UIView setAnimationDuration:0.3f];
            [UIView setAnimationRepeatCount:1];
            [UIView setAnimationBeginsFromCurrentState:YES];
            
            view_above.frame = CGRectMake(view_above.frame.origin.x, view_above.frame.origin.y + self.view.frame.size.height/4 + Iphone5_size(25, -10), view_above.frame.size.width, view_above.frame.size.height);
            
            UILabel *label_name = (UILabel *)[view_above viewWithTag:KWNLayerPageTag_name];
            label_name.frame = CGRectMake(label_name.frame.origin.x, label_name.frame.origin.y + Iphone5_size(35, 15), label_name.frame.size.width, label_name.frame.size.height);
            
            UILabel *label_level_ = (UILabel *)[view_above viewWithTag:KWNLayerPageTag_level];
            label_level_.frame = CGRectMake(label_level_.frame.origin.x + 15, label_level_.frame.origin.y + 20, label_level_.frame.size.width, label_level_.frame.size.height);
//            UIImageView *imageView_title_ = (UIImageView *)[view_above viewWithTag:KWNLayerPageTag_title];
//            imageView_title_.frame = CGRectMake(imageView_title_.frame.origin.x + 15, imageView_title_.frame.origin.y + 20, imageView_title_.frame.size.width, imageView_title_.frame.size.height);
//            UIImageView *imageView_level = (UIImageView *)[_view_above viewWithTag:KWNLayerPageTag_level];
//            imageView_level.frame = CGRectMake(imageView_level.frame.origin.x + 15, imageView_level.frame.origin.y + 20, imageView_level.frame.size.width, imageView_level.frame.size.height);
            
            UIView *view_animation = (UIView *)[self.view viewWithTag:KWNLayerPageTag_animation];
            view_animation.alpha = 1.0;
            
            UIImageView *imageView_portrait_ = (UIImageView *)[view_above viewWithTag:KWNLayerPageTag_portrait];
            imageView_portrait_.frame = CGRectMake(imageView_portrait_.frame.origin.x - 20, imageView_portrait_.frame.origin.y - 20, imageView_portrait_.frame.size.width + 40, imageView_portrait_.frame.size.height + 40);
            imageView_portrait_.layer.cornerRadius = 53.0;
            
            [UIView commitAnimations];
            view_scroll.alpha = 0.0;
        }
        else if (_bool_leave == YES){
            _bool_leave = NO;
        }

    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    if (scrollView.tag != TagOfView) {
        _bool_leave = YES;
        if(scrollView.contentOffset.y == 0){
            _bool_scroll = NO;
        }
        else{
            _bool_scroll = YES;
        }
    }
}

#pragma mark - 上滑手势 -
/**
 *  上滑手势
 */
- (void)handleSwipeFrom_up{
    if(_gestureUp.enabled == YES)
    {
        [self didClickButton_toBelow:nil];

    }
}

#pragma mark - 下滑手势 -
/**
 *  下滑手势
 */
- (void)handleSwipeFrom_down{
    if(_gestureDown.enabled == YES)
    {
        _gestureDown.enabled = NO;
        _gestureUp.enabled = YES;
        if(_bool_leave == YES){
            [UIView beginAnimations:@"101" context:nil];
            [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
            [UIView setAnimationDuration:0.3f];
            [UIView setAnimationRepeatCount:1];
            [UIView setAnimationBeginsFromCurrentState:YES];
            
            view_above.frame = CGRectMake(view_above.frame.origin.x, view_above.frame.origin.y + self.view.frame.size.height/4 + Iphone5_size(25, -10), view_above.frame.size.width, view_above.frame.size.height);
            
            UILabel *label_name = (UILabel *)[view_above viewWithTag:KWNLayerPageTag_name];
            label_name.frame = CGRectMake(label_name.frame.origin.x, label_name.frame.origin.y + Iphone5_size(35, 15), label_name.frame.size.width, label_name.frame.size.height);
            
            UILabel *label_level_ = (UILabel *)[view_above viewWithTag:KWNLayerPageTag_level];
            label_level_.frame = CGRectMake(label_level_.frame.origin.x + 15, label_level_.frame.origin.y + 20, label_level_.frame.size.width, label_level_.frame.size.height);
            //        UIImageView *imageView_title_ = (UIImageView *)[view_above viewWithTag:KWNLayerPageTag_title];
            //        imageView_title_.frame = CGRectMake(imageView_title_.frame.origin.x + 15, imageView_title_.frame.origin.y + 20, imageView_title_.frame.size.width, imageView_title_.frame.size.height);
            //UIImageView *imageView_level = (UIImageView *)[_view_above viewWithTag:KWNLayerPageTag_level];
            //imageView_level.frame = CGRectMake(imageView_level.frame.origin.x + 15, imageView_level.frame.origin.y + 20, imageView_level.frame.size.width, imageView_level.frame.size.height);
            
            UIView *view_animation = (UIView *)[self.view viewWithTag:KWNLayerPageTag_animation];
            view_animation.alpha = 1.0;
            
            UIImageView *imageView_portrait_ = (UIImageView *)[view_above viewWithTag:KWNLayerPageTag_portrait];
            imageView_portrait_.frame = CGRectMake(imageView_portrait_.frame.origin.x - 20, imageView_portrait_.frame.origin.y - 20, imageView_portrait_.frame.size.width + 40, imageView_portrait_.frame.size.height + 40);
            imageView_portrait_.layer.cornerRadius = 53.0;
            
            label_level.frame = CGRectMake(label_level.frame.origin.x, label_level.frame.origin.y - 10, label_level.frame.size.width + 20, label_level.frame.size.height + 9);
            label_level.layer.cornerRadius = 14;
            label_level.font = [UIFont fontWithName:@"Futura-CondensedExtraBold" size:16];
            
            [UIView commitAnimations];
            view_scroll.alpha = 0.0;
        }

    }

}

@end
